package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.ReturnList;
import com.atguigu.jxc.entity.ReturnListGoods;
import com.atguigu.jxc.entity.User;
import com.atguigu.jxc.service.ReturnListGoodsService;
import com.atguigu.jxc.service.ReturnListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * description
 *
 * @author SZ
 * @date 2022/9/25/11:49
 */
@RestController
@RequestMapping("/returnListGoods")
public class ReturnListGoodsController {
    @Autowired
    private ReturnListGoodsService returnListGoodsService;
    @Autowired
    private ReturnListService returnListService;
    @PostMapping("/save")
    public ServiceVO save(ReturnList returnList, String returnListGoodsStr, HttpSession session){
        //查看UserController看看登录的时候把user信息放哪了，放在了session里
        User user = (User) session.getAttribute ("currentUser");
        returnList.setUserId (user.getUserId ());
        return returnListGoodsService.save(returnList,returnListGoodsStr);
    }
    @PostMapping("/list")
    public List<ReturnList> list(String returnNumber,Integer supplierId, Integer state,String sTime,String eTime){
        return returnListService.getList(returnNumber,supplierId,state,sTime,eTime);
    }
    @PostMapping("/goodsList")
    public List<ReturnListGoods> getGoodsList(Integer returnListId){
        return returnListGoodsService.getGoodsList(returnListId);
    }
    @PostMapping("/delete")
    public ServiceVO deleteById(Integer returnListId){
        return returnListService.deleteById(returnListId);
    }

}
